<template>
  <div class="container">
    <div class="box box-ver h-p100">
      <div class="box-f1 of-y-s">
        <div class="total">
          <div>您本次的其他费用报销金额合计为</div>
          <div class="box box-ac amount">
            <div>¥&nbsp;</div>
            <input v-model="total" readonly v-limit-money class="box-f1" type="number">
          </div>
        </div>
        <div class="list">
          <div class="item box box-ver">
            <div>其他费用金额</div>
            <div class="box box-ac amount">
              <div>¥&nbsp;</div>
              <input v-model="person.OTHEREXPENSE" v-limit-money class="box-f1" type="number">
            </div>
            <div class="tips box">
              <div class="icon icon-invoice-tips"></div>
              <div class="tc-666 box-f1">
                可用来填写差旅报销超出标准合理部分费用，如多人出差共用一张住宿费发票报销、机票、火车票及交通费超出标准等；
                如有其他费用产生，请填写其他费用原因说明；
              </div>
            </div>
            <div v-if="this.person.OTHEREXPENSE > 0" class="cause">
              <div class="text">请输入其他费用说明（必填）</div>
              <input v-model="person.OTHERCAUSE" maxlength="15" placeholder="请输入费用说明" type="text">
            </div>
          </div>
          <div class="item box box-ver">
            <div>出差补助金额</div>
            <div class="box box-ac amount">
              <div>¥&nbsp;</div>
              <input v-limit-money class="box-f1" v-model="person.EVENTIONSUBSIDY" type="number">
            </div>
            <div class="tips box">
              <div class="icon icon-invoice-tips"></div>
              <div class="tc-666 box-f1">
                出差补助按每人每天100元金额补贴，出差超出10天（不含10天）的部分补助额度减半；（以各公司实际补贴制度为准）举例：出差15天，补助为10*100+（15-10）*5=1250元
              </div>
            </div>
          </div>
        </div>
      </div>
      <div @click="sure()" class="btn-bot">确定</div>
    </div>
  </div>
</template>

<script>
import { mapState } from 'vuex'
export default {
  name: 'caiBaoFeeQiTa',
  data () {
    return {
      billIndex: '',
      personIndex: '',
      person: {
        EVENTIONSUBSIDY: '', // 出差补助
        OTHEREXPENSE: '', // 其他费用
        OTHERCAUSE: '' // 其他费用说明
      }
    }
  },
  computed: {
    ...mapState(['bizAccountBill']),
    total () {
      let OTHEREXPENSE = this.person.OTHEREXPENSE || 0
      let EVENTIONSUBSIDY = this.person.EVENTIONSUBSIDY || 0
      let total = (+OTHEREXPENSE) + (+EVENTIONSUBSIDY)
      return total.toFixed(2)
    }
  },
  created () {
    this.billIndex = this.$route.query.billIndex
    this.personIndex = this.$route.query.personIndex
    let person = this.bizAccountBill.marchInfos[this.billIndex].travelPerson[this.personIndex]
    this.person = Object.assign({}, this.person, person)
  },
  mounted () {
  },
  methods: {
    sure () {
      if (+this.person.OTHEREXPENSE > 0) {
        if (!this.person.OTHERCAUSE) {
          return this.$tools.openToast({
            msg: '请填写其他费用说明',
            duration: 2000
          })
        }
      }
      this.person.qtTotal = this.total
      this.bizAccountBill.marchInfos[this.billIndex].travelPerson[this.personIndex] = this.person
      this.$store.commit('bizAccountBill', {
        marchInfos: this.bizAccountBill.marchInfos
      })
      this.$router.go(-1)
    }
  }
}
</script>

<style lang="scss" scoped>
@import '../assets/css/caiBaoFee';
.cause{
  padding-bottom:.2rem;
  .text{
    color:#555;
    padding-top:.2rem;
    // border-top: 1px solid #DDD;
  }
  input{
    width:100%;
    line-height: .5rem;
    border-bottom:1px solid #333;
  }
}
.btn-bot{
  position: relative;
}
</style>
